package com.mollytask.superadmin;

import android.widget.TextView;

import com.mollytask.R;
import com.mollytask.base.BaseDetailActivity;
import com.mollytask.bean.CheckRecord;
import com.mollytask.bean.DataFill;
import com.mollytask.bean.Institution;

import java.util.List;

import butterknife.BindView;
import cn.bmob.v3.BmobQuery;
import cn.bmob.v3.exception.BmobException;
import cn.bmob.v3.listener.FindListener;

public class DataRecordDetailActivity extends BaseDetailActivity {


    @BindView(R.id.check_record_result_name)
    TextView mCheckName;
    @BindView(R.id.check_record_time)
    TextView mCheckTime;
    @BindView(R.id.check_record_status_text)
    TextView mCheckStatus;
    @BindView(R.id.check_result_message_text)
    TextView mCheckMessage;


    @Override
    public int setLayout() {
        return R.layout.activity_data_record_detail;
    }

    @Override
    public void receiveData() {
        mDataFill = (DataFill) getIntent().getSerializableExtra("dataFillResult");
        mInstitution = (Institution) getIntent().getSerializableExtra("institution");
    }

    @Override
    public void init() {
        mCheckName.setText(mDataFill.getmInName());
        mCheckTime.setText(mDataFill.getmFillId().substring(9, 13) + "年第" + mDataFill.getmFillId().substring(13, 14) + "季度");

        if (mDataFill.getStatus().equals(0)) {
            mCheckStatus.setTextColor(getResources().getColor(android.R.color.holo_red_light));
            mCheckStatus.setText("待审核");

        } else if (mDataFill.getStatus().equals(1)) {
            mCheckStatus.setTextColor(getResources().getColor(R.color.status_yes));

            mCheckStatus.setText("已通过");


        } else if (mDataFill.getStatus().equals(2)) {
            mCheckStatus.setTextColor(getResources().getColor(R.color.status_not));

            mCheckStatus.setText("未通过");


        }

        BmobQuery<CheckRecord> bmobQuery = new BmobQuery<>();
        bmobQuery.addWhereEqualTo("fillId", mDataFill.getmFillId());
        bmobQuery.findObjects(new FindListener<CheckRecord>() {
            @Override
            public void done(List<CheckRecord> list, BmobException e) {
                if (e == null) {
                    mCheckMessage.setText(list.get(0).getCheckMessage());
                }
            }
        });
    }
}
